package com.dt.platform.oa.page;

import org.github.foxnic.web.framework.view.controller.ViewController;

import org.github.foxnic.web.session.SessionUser;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import com.dt.platform.proxy.oa.ProjectServiceProxy;
import javax.servlet.http.HttpServletRequest;
/**
 * <p>
 * 项目管理模版页面控制器
 * </p>
 * @author 金杰 , maillank@qq.com
 * @since 2025-06-19 21:01:03
*/

@Controller("OaProjectPageController")
@RequestMapping(ProjectPageController.prefix)
public class ProjectPageController extends ViewController {

	public static final String prefix="business/oa/project";

	private ProjectServiceProxy proxy;

	/**
	 * 获得代理对象<br>
	 * 1、单体应用时，在应用内部调用；<br>
	 * 2、前后端分离时，通过配置，以Rest方式调用后端；<br>
	 * 3、微服务时，通过feign调用; <br>
	 * */
	public ProjectServiceProxy proxy() {
		if(proxy==null) {
			proxy=ProjectServiceProxy.api();
		}
		return proxy;
	}

	/**
	 * 项目管理 功能主页面
	 */
	@RequestMapping("/my_list.html")
	public String mylist(Model model,HttpServletRequest request,String dataRange,String pageType) {
		model.addAttribute("dataRange",dataRange);
		model.addAttribute("pageType",pageType);
		return getTemplatePath(prefix,"my_list");
	}


	/**
	 * 项目管理 功能主页面
	 */
	@RequestMapping("/project_list.html")
	public String list(Model model,HttpServletRequest request,String dataRange,String pageType) {
		model.addAttribute("dataRange",dataRange);
		model.addAttribute("pageType",pageType);
		return getTemplatePath(prefix,"project_list");
	}

	/**
	 * 项目管理 表单页面
	 */
	@RequestMapping("/project_form.html")
	public String form(Model model,HttpServletRequest request , String id) {

		SessionUser user=SessionUser.getCurrent();
		String empId=user.getActivatedEmployeeId();
		String userName=user.getUser().getActivatedEmployeeName();

		String curUserOrgName=user.getPrimaryOrganization()!=null?user.getPrimaryOrganization().getFullName():null;
		String curUserOrgId =user.getPrimaryOrganizationId();

		model.addAttribute("curUserOrgName",curUserOrgName);
		model.addAttribute("curUserOrgId",curUserOrgId);


		model.addAttribute("curEmpId",empId);
		model.addAttribute("curUserName",userName);

		return getTemplatePath(prefix,"project_form");
	}
}